home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / infor / tsptp.zip / RMATH.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-09  |  2KB  |  71 lines

  1. (******************************************************************************)
  2. (*                                 RMATH.MOD                                  *)
  3. (*                            Real Math Benchmark.                            *)
  4. (******************************************************************************)
  5.  
  6. PROGRAM Rmath(Output);
  7.  
  8. (******************************************************************************)
  9. (*                                TIMING                                      *)
  10. (******************************************************************************)
  11.  
  12. (*$IFNDEF TopSpeed *)
  13.  (*%F TRUE   *** Compile for Turbo Pascal ***)
  14.   USES TPBench;
  15.  (*%E*)
  16. (*$ELSE     *** Compile for TopSpeed Pascal ***)
  17.   IMPORT TSBench *;
  18. (*$ENDIF *)
  19.  
  20. (******************************************************************************)
  21.  
  22.   VAR
  23.     X, Y : BmReal;
  24.  
  25.   PROCEDURE RealMath;
  26.     VAR I : BmInt;
  27.   BEGIN
  28.  
  29.     X := 0.0;
  30.     Y := 9.9;
  31.  
  32.     FOR I := 1 TO 1000 DO
  33.       X := X + ((Y * Y - Y) / Y);
  34.  
  35.   END;
  36.  
  37. BEGIN
  38.   WriteLn('RealMath Benchmark');
  39.  
  40. (******************************************************************************)
  41. (*  Compute the looping overhead.  The Dummy procedure must have some side-   *)
  42. (*  effect so that it is not optimised out of existence.                      *)
  43. (******************************************************************************)
  44.  
  45.   StartTimer;                                   (* Start the clock.           *)
  46.  
  47.   REPEAT
  48.     Dummy;
  49.   UNTIL NullTimesUp;
  50.  
  51. (******************************************************************************)
  52. (*  Now run the benchmark.  Note that the Dummy procedure is also called so   *)
  53. (*  that we can eliminate its overhead from the looping overhead.             *)
  54. (******************************************************************************)
  55.  
  56.   StartTimer;                                   (* Start the clock.           *)
  57.  
  58.   REPEAT
  59.     RealMath;
  60.     Dummy
  61.   UNTIL BenchTimesUp;
  62.  
  63. (******************************************************************************)
  64.  
  65.   ReportTimes;
  66.  
  67.   WriteLn;
  68.   WriteLn('Result: X = ', X:10);
  69.  
  70. END.
  71.